<!DOCTYPE html>
<!--suppress ALL-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div id="logoArea" class="navbar">
    <div class="navbar">
        <img src="../static/dl.png" height="500" width="100%" alt="">
    </div>
</div>
<form class="form-horizontal" role="form"  >
    <div class="form-group">
        <label class="col-sm-2 control-label">用户名</label>
        <div class="col-sm-3">
            <input type="text" name="loginName" class="form-control"
                   placeholder="请输入用户名">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">密码</label>
        <div class="col-sm-3">
            <input type="text" name="loginPwd" class="form-control"
                   placeholder="请输入密码">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-3">
            <button type="submit" class="btn btn-default" onclick="Lock()">登录</button>
            <button type="button" class="btn btn-default" onclick="addUser()">注册</button>
        </div>
    </div>
</form>
</body>
<script>
    function Lock() {
       $.ajax({
           type:"post",
           url:"/user/login",
           data:$("form").serialize(),
           dataType:"json",
           success(obj){
               if (obj==0){
                   alert("用户名或密码错误");
                   location.reload();
               }else if (obj == 1){
                   alert("登录成功");
                   location.href="/sec/list"
               }
           }
       })
    }
    function addUser() {
        location="/user/add"
    }
</script>
</html>

